import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import*
testCase="DBshop026_商品咨询删除"
dr=openBrowser(urlAdmin)
DBshopLoginAdmin(dr)
DBshopEnterMenu2(dr,"商品管理","商品咨询")
#删除前获取咨询数
str=dr.find_element_by_xpath('//body').text
num1=reGetString(str,'咨询数：','\)')
# 3.后台登录，商品管理商品咨询，点击“删除”按钮，，确认删除，删除成功。
dr.find_element_by_link_text("删除").click()
time.sleep(1)
dr.switch_to.alert.accept()
time.sleep(3)
#删除后获取咨询数
str=dr.find_element_by_xpath('//body').text
num2=reGetString(str,'咨询数：','\)')
#删除后的咨询数+1=删除前的咨询数
num1=int(num1)
num2=int(num2)
if num1==num2+1:
    writeLog("%s 测试通过" % (testCase))
else:
    writeLog("%s 测试失败" % (testCase))
    getPhoto(dr)
# try:
#     dr.find_element_by_link_text("删除").is_displayed()
#     writeLog("%s 测试失败" % (testCase))
#     getPhoto(dr)
# except:
#     writeLog("%s 测试通过" % (testCase))
dr.quit()